   <#include
"../common/com.html"/> <@layout>
   	
<!-- ace styles -->
<link rel="stylesheet" href="${ctx}/static/assets/css/ace.min.css" />

<script type="text/javascript">
    /**
     * 新增
     */
    function saveModel() {
        var id=document.getElementById("id").value;
              if(Validator.Validate(document.getElementById('form1'))){
        } else {
            return;
        }
        
        url = '';
        if(id==""){
            url = '${ctx}/tbMeetClass/save';
        }     else{
            url = '${ctx}/tbMeetClass/update';
        }
        $('#form1').form('submit', {
            url : url,
            onSubmit : function() {
                return $(this).form('validate');
            },
            success : function(data) {
                alert(data);
                parent.location.reload();
                //window.location.href=' ${ctx}/tbMeetClass';
            }
        });

    }
</script>
<div class="page-content">
<div class="row-fluid">
						<div class="span12">
                <form class="form-horizontal"  id="form1" method="post" >
                	<input type="hidden"  name="id" id="id"    >
								 	
						<div class="control-group">
									<label class="control-label">会议:</label>
						<div class="controls"> 
						<input id="meetid_val" type="hidden" class="easyui-numberbox"/> 
						
						<select id="meetid" name="meetid" name="type" id="type" panelheight="80" 
							style="width: 205px;" dataType="Require" msg="请选择会议" >
                        </select>
                         							
						</div>
						</div>
						
						<div class="control-group">
									<label class="control-label">课程题目:</label>
						<div class="controls"> <input id="title"
								name="title" type="text" dataType="Require" msg="请输入题目"
								  style="min-height: 24px;"  />
							</div>
						</div>
								  		
								  								<div class="control-group">
									<label class="control-label">开始时间:</label>
						<div class="controls"> <input id="starttime"  dataType="Require" msg="请输入开始时间"
								name="starttime" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
								  style="min-height: 24px;"  />
							</div>
								 	</div>
								  								<div class="control-group">
									<label class="control-label">结束时间:</label>
						<div class="controls"> <input id="endtime" dataType="Require" msg="请输入结束时间"
								name="endtime" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
								  style="min-height: 24px;"  />
							</div>
								 	</div>
								  								<div class="control-group">
									<label class="control-label">课程费用:</label>
						<div class="controls">
						<input id="feeclass"  name="feeclass" type="text" 
								style="min-height: 24px;" dataType="Number" msg="费用必须为数字" />
						</div>
						</div>
						
						<div class="control-group">
									<label class="control-label">提成:</label>
						<div class="controls"> 
						<input id="feeperson" name="feeperson" type="text" 
							style="min-height: 24px;"  dataType="Number" msg="费用必须为数字"  />
						</div>
						</div>
						
						<div class="control-group">
									<label class="control-label">老师:</label>
						<div class="controls"> 
						<#-- 
						<input id="teacherid" name="teacherid" type="text" style="min-height: 24px;"  />
						-->
						<input id="teacherid_val" type="hidden" class="easyui-numberbox"/> 
						
						<select id="teacherid" name="teacherid" name="type" id="type" panelheight="80" 
							style="width: 205px;" dataType="Require" msg="请选择老师" >
                        </select>
						</div>
						</div>
						
						<div class="control-group">
									<label class="control-label">省:</label>
						<div class="controls"> 
						<input id="addresscity_val" type="hidden" class="easyui-numberbox"/> 
						
						<select id="addresscity" name="addresscity" name="type" id="type" panelheight="80" 
							style="width: 205px;" dataType="Require" msg="请选择省">
                        </select>
                        
							</div>
						</div>
						
						<div class="control-group">
									<label class="control-label">县:</label>
						<div class="controls"> 
						<input id="addressxian_val" type="hidden" class="easyui-numberbox"/> 
						
						<select id="addressxian" name="addressxian" name="type" id="type" panelheight="80" 
							style="width: 205px;" dataType="Require" msg="请选择县" >
                        </select>
                        
							</div>
						</div>

						<div class="control-group">
									<label class="control-label">地址具体:</label>
						<div class="controls"> <input id="addressother"
								name="addressother" type="text"
								  style="min-height: 24px;"  />
							</div>
						</div>
						
						<div id="transmitcount_wrap" class="control-group">
									<label class="control-label">转发量:</label>
						<div class="controls"> <span id="transmitcount" ></span>
							</div>
						</div>
						
						<div  id="createtime_wrap" class="control-group">
									<label class="control-label">创建时间:</label>
						<div class="controls"> <span id="createtime" ></span>
							</div>
						</div>
								  				
             </form>
        </div>
        	<div class="span12 center">
				<a  class="btn btn-info btn-small" onclick="saveModel()">确定
				<a href="#"  class="btn btn-danger btn-small bigger-110"  onclick="parent.closeDialog();"  >取消 </a>
		</div>
    </div>
</div>

    </body>
   
    <script>
    	 /**
    * 修改页面使用
    */
    $(function(){
    	
    	
	 <#list newlist as m>
			 document.getElementById("id").value  
			 =  '${(m.id)!}';
	        document.getElementById("title").value  
	        =  '${(m.title)!}';
	        document.getElementById("starttime").value  
	        =  '${(m.starttime)!}';
	        document.getElementById("endtime").value  
	        =  '${(m.endtime)!}';
	        document.getElementById("feeclass").value  
	        =  '${(m.feeclass)!}';
	        document.getElementById("feeperson").value  
	        =  '${(m.feeperson)!}';
	        document.getElementById("addressother").value  
	        =  '${(m.addressother)!}';
	        
	        
	    	// 记录选择字段
	        $("#teacherid_val").val('${(m.teacherid)!}');
	     	$("#meetid_val").val('${(m.meetid)!}');
	     	$("#addresscity_val").val('${(m.addresscity)!}');
	     	$("#addressxian_val").val('${(m.addressxian)!}');
	     	$("#transmitcount").html('${(m.transmitcount)!}');
	     	$("#createtime").html('${(m.createtime)!}');
	</#list>
		
	 	var id=$("#id").val();
		if(id==""){
			$('#transmitcount_wrap').hide();
			$('#createtime_wrap').hide();
		}
	
		//会议初始化
		var url = "${ctx}/tbMeet/queryAll";
		$.ajax({
		    url:url,
			data : "",
			success : function success(data) {
				$.each(data,function(key, val) {
					if(data[key].id=="0"){
						$("#meetid").append("<option  value=''>请选择会议</option>");
					}else{
						$("#meetid").append("<option  value='"+data[key].id+"'>" + data[key].text + "</option>");
					}
				});
				// 选择
				$("#meetid").val($("#meetid_val").val());
				
			},
			dataType : "json"
		});
		
		//老师初始化
		var url = "${ctx}/tbMeetTeacher/queryAll";
		$.ajax({
		    url:url,
			data : "",
			success : function success(data) {
				$.each(data,function(key, val) {
					if(data[key].id=="0"){
						$("#teacherid").append("<option  value=''>请选择老师</option>");
					}else{
						$("#teacherid").append("<option  value='"+data[key].id+"'>" + data[key].text + "</option>");
					}
				});
				// 选择
				$("#teacherid").val($("#teacherid_val").val());
				
			},
			dataType : "json"
		});
		
		//省初始化
		var city_url = "${ctx}/address/city";
		// 新增不设置
		$.ajax({
		    url:city_url,
			data : "",
			success : function success(data) {
				$.each(data,function(key, val) {
					if(data[key].id=="0"){
						$("#addresscity").append("<option  value=''>请选择</option>");
					}else{
						$("#addresscity").append("<option  value='"+data[key].code+"'>" + data[key].name + "</option>");
					}
				});
				// 选择
				$("#addresscity").val($("#addresscity_val").val());
				
			},
			dataType : "json"
		});
		
		
		//县初始化
		if(id!=""){
			var city = $("#addresscity_val").val();
			loadXian(city);
		} else {
			$("#addressxian").append("<option  value=''>请先选择省</option>");
		}
		
		$("#addresscity").on("change",function(){
			var city = $("#addresscity").val();
			$("#addressxian").html('');
			loadXian(city);
		});
		
		function loadXian(city){
			var xian_url = "${ctx}/address/xian";
			$.ajax({
			    url:xian_url,
				data : "city="+city,
				success : function success(data) {
					$.each(data,function(key, val) {
						if(data[key].id=="0"){
							$("#addressxian").append("<option  value=''>" + data[key].name + "</option>");
						}else{
							$("#addressxian").append("<option  value='"+data[key].code+"'>" + data[key].name + "</option>");
						}
					});
					// 初始化选择
					$("#addressxian").val($("#addressxian_val").val());
					
				},
				dataType : "json"
			});
		}
	
    });
    </script>
 </@layout> 
